Import design standards from CSV template to Dgnlib
The below code imports the design standards from the csv template to active design standard from DGNLIB.
The below image shows the content from the sample .csv template file.
//Required References
using System;
using System.IO;
using Bentley.CifNET.DesignStandardsModel;
public void ImportDesignStandardsToLibrary()
{
//Get Design standard model manager
Bentley.CifNET.DesignStandardsModel.DesignStandardModelManager designStandardModelManager = DesignStandardModelManager.Instance;
//Get active design standard
Bentley.CifNET.DesignStandardsModel.DesignStandard activeDesignStandard = designStandardModelManager.CurrentDesignStandard;
//.CSV file name to read data for adding the design standards
string fileName = "D:\\DrawingProduction\\DesignStandards.csv";
//Read all lines from csv file into array of strings
String[] lines = File.ReadAllLines(fileName);
for (int itr = 1; itr < lines.Length; itr++)
{
string[] values = lines[itr].Split(',');
if (values.Length != 8) continue;
//Read name for design standard
string designStandardName = values[0];
//Add design standard to current active design standard library
DesignStandard newDesignStandard = activeDesignStandard.AddDesignStandard(designStandardName);
newDesignStandard.DefaultRadius = System.Convert.ToDouble(values[1]);
newDesignStandard.MinRadius = System.Convert.ToDouble(values[2]);
newDesignStandard.MaxRadius = System.Convert.ToDouble(values[3]);
newDesignStandard.MinArcLength = System.Convert.ToDouble(values[4]);
newDesignStandard.MaxArcLength = System.Convert.ToDouble(values[5]);
newDesignStandard.Speed = System.Convert.ToDouble(values[6]);
newDesignStandard.IncludeTransitions = System.Convert.ToBoolean(values[7]);
}
}